Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct docs for contact-summary field appliesIf #1718

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

jkuester
Copy link
Contributor

@jkuester jkuester commented Nov 19, 2024

Description

Currently the contact-summary fields docs indicate that the appliesIf property for a field could be:

function() or boolean

However, checking the actual code in cht-conf, there is no way that a boolean value could be set here with a semantically logical meaning.

        if (!f.appliesIf || f.appliesIf()) {

If you set appliesIf = false, this if-statement would resolve true because !false === true. If you set appliesIf = true, then we get the error TypeError: f.appliesIf is not a function because it will try to call appliesIf as a function when the property exists.

This PR simply updates the docs to clarify that appliesIf can only be a function.

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@jkuester jkuester requested a review from kennsippell November 19, 2024 21:56
@jkuester
Copy link
Contributor Author

@kennsippell when you have a second, can you just confirm this passes your smell test? 🙏

cc @tatilepizs

@@ -55,7 +55,7 @@ Each field that can be shown on a contact's profile is defined as an object in t
| `width` | `integer` | The horizontal space for the field. Common values are 12 for full width, 6 for half width, or 3 for quarter width. Default 12. | no |
| `translate` | `boolean` | Whether or not to translate the `value`. Defaults to false. | no |
| `context` | `object` | When `translate: true` and `value` uses [translation variables](https://angular-translate.github.io/docs/#/guide/06_variable-replacement), this value should provide the translation variables. | no |
| `appliesIf` | `function()` or `boolean` | Return true if the field should be shown. | no |
| `appliesIf` | `function()` | Return `true` if the field should be shown, and `false` if it should be hidden. Default is `true`. | no |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno how much detail to go into. Smells fine but slightly incomplete... it's a bit more complicated than saying "false if hidden" because visibility is determined by appliesIf && !resolvedIf. I think this is explained somewhat well here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for having a look!

visibility is determined by appliesIf && !resolvedIf

These docs are specifically for the contact-summary fields. Unless I am totally missing something, I think that resolvedIf is just for tasks. In the tasks world, yes, visibility (and everything else 😅) is more complicated, but here for the contact summary fields, I think the logic is more straight forward.

That being said, if I totally misunderstood what you meant, let me know and I can open a new PR to better clarify things!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake

@jkuester jkuester merged commit 50d0de2 into main Nov 20, 2024
2 checks passed
@jkuester jkuester deleted the contact-summary-appliesIf branch November 20, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants